interface UserState {
	isLogin: true,
	avator: string
	nickname: string
	token: string
}

const initState: UserState = {
	isLogin: true,
	avator: '',
	nickname: '',
	token: ''
}
const SET_USER = 'SET_USER'

interface Set_USER {
	type: typeof SET_USER
	payload: UserState
}

export function setUserAction(payload: UserState) : Set_USER {
	return { type: SET_USER, payload }
}


type UserAction = Set_USER


export default (state = initState, action: UserAction) => {
	switch(action.type) {
		case SET_USER: {
			return {
				...state,
				...action.payload
			}
		}
		default: return state
	}
}